package org.jackysoft.entity;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import org.jackysoft.entity.AbstractNoIdEntity;

/**
 * 产品定额
 **/
@Entity
@org.hibernate.annotations.Entity(dynamicUpdate=true,dynamicInsert=true) 
public class ProductQuota extends AbstractNoIdEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1814473051472414625L;
			
	
	private Double  consume = 1D;
	
	
	private Product owner;	
	
	private Product host;
	
	
	public ProductQuota(){}
	
	/**
	 * 关联产品
	 * @return 
	 * 此定额项所关联到的产品
	 * */
	@Id
	@ManyToOne
	public Product getOwner() {
		return owner;
	}

	public void setOwner(Product product) {
		this.owner = product;
	}
	
	/**
	 * 消耗定额
	 * */
	public Double getConsume() {
		return consume;
	}

	public void setConsume(Double consume) {
		this.consume = consume;
	}

	/**
	 * 隶属产品
	 * @return 
	 * 此定额项所隶属的产品
	 * */
	@Id
	@ManyToOne
	public Product getHost() {
		return host;
	}

	public void setHost(Product belongTo) {
		this.host = belongTo;
	}
	
	
	@Override
	public String toString(){
		return this.host.code+"->"+this.owner.code+"["+consume+"]";
	}
	
}
